package com.sfx.concurrent.demo.线程基础.线程的创建;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

class MyCallable implements Callable<Integer> {

    @Override
    public Integer call() throws Exception {
        return 10;
    }
}

public class TestThread5 {

    public static void main(String[] args) {

        FutureTask<Integer> futureTask = new FutureTask<>(new MyCallable());

        Thread thread = new Thread(futureTask);
        thread.start();
        try {
            Integer integer = futureTask.get();
            System.out.println(integer);
        } catch (InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }
    }
}
